﻿@{
    var returnUrl = "~/LoginSuccess";
    var title = "Login with Foursquare";
}

<h3>Authentication Flow</h3>

<h4>Step 1: Call the Foursquare.GetLoginLink() Method</h4>
<p>Use the following code to display the Foursquare login link:</p>

<pre class="code">
@@Foursquare.GetLoginLink(title, returnUrl)
</pre>

<h4>Step 2: Configure the callback page on your site</h4>
<p>The helper uses a pre-defined callback page located at <i>/Foursquare/RequestToken.cshtml</i>. This page receives the access token from Foursquare and redirects the user to the return url specified in the GetLoginLink() method:</p>
<pre class="code">
@@{    
    var accessToken = Foursquare.GetAccessToken();
    
    Session["accessToken"] = accessToken;   
    ...
    Context.RedirectLocal(returnUrl);
}
</pre>

<p>By default, the pre-defined callback page stores the access token in the Session object to use it in future API calls. In a complete implementation, <strong>you should store the access token in a persistent storage</strong> (e.g. a database).</p>

<div class="message info">
    <span><strong>Note: </strong>You can specify a different url for the callback page in the Initialize method (for more details, see the helper reference in documentation).</span>
</div>

<h4>Verification</h4>

<p>Click the following link to authenticate with Foursquare using your account:</p>

<pre class="code">
@@Foursquare.GetLoginLink("@title", "@returnUrl")
</pre>

@Foursquare.GetLoginLink(title, returnUrl)


